#include <stdio.h>
#include <string.h>

long power (long a, long b)
{
	long res = 1;
	long i;

	for (i = 0; i < b; i++)
		res *= a;

	return res;
}

int main()
{

	char col[] = "AZZ", c;

	long i, baseval, offset, colnum = 0;
	int n;

	n = strlen (col);

	/* reverse the string for easy access */
	for (i = 0; i < n/2; i++) {
		c = col [i];
		col [i] = col [n - i - 1];
		col [n - i - 1] = c;
	}

	for (i = 0; i < n; i++) {
		baseval = power (26, i);

		offset = col [i] - 'A' + 1;

		colnum += baseval * offset;
	}

	/* reverse the string for printing */
	for (i = 0; i < n/2; i++) {
		c = col [i];
		col [i] = col [n - i - 1];
		col [n - i - 1] = c;
	}


	printf ("Column number of %s is %ld\n", col, colnum);

	return 0;
}
